//
//  LXNewFeatureCell.m
//  绿稀全球购
//
//  Created by 诸葛孔明 on 16/7/16.
//  Copyright © 2016年 SJT. All rights reserved.
//

#import "LXNewFeatureCell.h"

#import "LXNavigationController.h"

#import "HomeViewController.h"

@interface LXNewFeatureCell()

@property(nonatomic,weak) UIImageView *imageView;
@property(nonatomic,weak) UIButton *startButton;

@end

@implementation LXNewFeatureCell


-(id)initWithFrame:(CGRect)frame{
    if(self = [super initWithFrame:frame]){
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        [btn sizeToFit];
        btn.size = CGSizeMake(ScreenWidth*0.6, 40);
        [btn setTitle:@"立即体验" forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [btn setBackgroundColor:RGBColor(37,167,73)];
        [btn addTarget:self action:@selector(start) forControlEvents:UIControlEventTouchUpInside];
        [btn addRadius:10];
        btn.centerX = ScreenWidth*0.5;
        btn.y = ScreenHeight - 120;
        self.startButton = btn;
        [self.imageView addSubview:self.startButton];
    }
    return self;
}

- (UIImageView *)imageView
{
    if (!_imageView) {
        UIImageView *imageV = [[UIImageView alloc] initWithFrame:self.bounds];
        [self.contentView addSubview:imageV];
        imageV.userInteractionEnabled = YES;
        _imageView = imageV;
    }
    return _imageView;
}

- (void)setImage:(UIImage *)image
{
    _image = image;
    self.imageView.image = image;
}


-(void)setIslastPage:(BOOL)islastPage{
    _islastPage = islastPage;

    self.startButton.hidden = !_islastPage;

}

- (void)start
{
    HomeViewController * rootVC = [[HomeViewController alloc] init];
    LXNavigationController * nvc = [[LXNavigationController alloc] initWithRootViewController:rootVC];
    [UIApplication sharedApplication].keyWindow.rootViewController = nvc;
}

@end
